@extends('admin.mainlayout')
@section('js')
<script>
    window.onload = function(){

        /********快闪重定向*********/
        var message = "{{Session::get('message')}}";
        $(window).ready(function () {
            if (message) {
                layer.msg(message, {
                    time: 3000,

                });
            }
        });
        /********快闪重定向*********/


        var oFile1 = document.getElementById('Filedata1');
        var oFile2 = document.getElementById('Filedata2');
        var oImg1 = document.getElementById('img1');
        var oImg2 = document.getElementById('img2');
        var oHid1 = document.getElementById('hid1');
        var oHid2 = document.getElementById('hid2');

        

        oFile1.onchange = function(){

            var file = this.files[0];

            var reader = new FileReader();

            reader.readAsDataURL(file);   //将文件读取为DataUrl

            //读完了之后就能调取数据了
            reader.onload = function(){
                //console.log(reader.result);
                //在div中添加dom
                //在隐藏标签中添加value
                oImg1.src = reader.result;
                oHid1.value = reader.result;
            }

        }


        oFile2.onchange = function(){

            var file = this.files[0];

            var reader = new FileReader();

            reader.readAsDataURL(file);   //将文件读取为DataUrl

            //读完了之后就能调取数据了
            reader.onload = function(){
                //console.log(reader.result);
                //在div中添加dom
                //在隐藏标签中添加value
                oImg2.src = reader.result;
                oHid2.value = reader.result;
            }

        }


//        var oFileUrl = document.getElementById('wenjian_url');
//        var oHidUrl = document.getElementById('wenjian');
//        oFileUrl.onchange = function(){
//
//            var file = this.files[0];
//
//            var reader = new FileReader();
//
//            reader.readAsDataURL(file);   //将文件读取为DataUrl
//
//            //读完了之后就能调取数据了
//            reader.onload = function(){
//                //console.log(reader.result);
//                //在div中添加dom
//                //在隐藏标签中添加value
//                oHidUrl.value = reader.result;
//            }
//
//        }

    }

</script>
@endsection
@section('content')
    <div class="main-wrap">
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">众筹设置</span></div>
        </div>
        <div class="result-wrap">
            <form action="{{urlAdmin('Zhongchou','postEdit')}}" method="post" id="myform" name="myform" enctype="multipart/form-data">
                {{csrf_field()}}
                <div class="config-items">
                    <div class="config-title">
                        <h1><i class="icon-font">&#xe00a;</i>众筹详细信息设置</h1>
                    </div>
                    <div class="result-content">
                        <table width="100%" class="insert-tab">
                            <tbody>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>图片1：</th>
                                <td><img id='img1' style="width:40px;" src="/{{$data['url1']}}"><input id='hid1' type="hidden" name="url1" value="" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹封面图片上传：</th>
                                <td><input type="file" id='Filedata1' name="Filedata1" class="common-text"></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>图片2：</th>
                                <td><img id='img2' style="width:40px;" src="/{{$data['url2']}}"><input id='hid2' type="hidden" name="url2" value="" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹详情图片上传：</th>
                                <td><input type="file" id='Filedata2' name="Filedata2" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>需下载文件上传：</th>
                                <td><input type="file" id='wenjian_url' name="wenjian_url" class="common-text">
                                    <input type="hidden" id='wenjian' name="wenjian" value="">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>标题：</th>
                                <td><input type="text" id="" value="{{$data['title']}}" size="85" name="title" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹币种：</th>
                                <td>
                                    <select name="currency_id">
                                            @foreach($currency as $v)
                                            <option value="{{$v['currency_id']}}" class="common-text"
                                            @if($v['currency_id']==$data['currency_id'])
                                            selected
                                            @endif
                                            >
                                            {{$v['currency_name']}}
                                            </option>
                                            @endforeach
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹购买币种：</th>
                                <td>
                                    <select name="buy_currency_id">
                                        <option value="0">人民币</option>
                                        @foreach($currency as $v)
                                            <option value="{{$v['currency_id']}}" class="common-text"
                                            @if($v['currency_id']==$data['buy_currency_id'])
                                            selected
                                            @endif
                                            >
                                                {{$v['currency_name']}}
                                            </option>
                                        @endforeach
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <th><i class="require-red">*</i>众筹获得币种是否冻结：</th>
                                <td>
                                    <select name="is_forzen" onchange="show_bl();" id="re_forzen">
                                        <option value='0'
                                        @if($data['is_forzen']==0)
                                        selected
                                        @endif
                                        >冻结</option>
                                        <option value='1'
                                        @if($data['is_forzen']==1)
                                        selected
                                        @endif
                                        >可用</option>
                                    </select>
                                    <span id="re_span">&nbsp;&nbsp;&nbsp;&nbsp;解冻比例：<input type="text" name="remove_forzen_bili" value="{{$data['remove_forzen_bili']}}" class="common-text" id="re_bl"/>%</span>
                                    <span id="re_cycle">&nbsp;&nbsp;&nbsp;&nbsp;解冻周期：<input type="text" name="remove_forzen_cycle" value="{{$data['remove_forzen_cycle']}}" class="common-text" id="re_bl"/>天</span>
                                </td>

                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹发售量：</th>
                                <td><input type="text" id="" value="{{$data['num']}}" size="85" name="num" class="common-text">

                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹保留量：</th>
                                <td><input type="text" id="" value="{{$data['num_nosell']}}" size="85" name="num_nosell" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹价格：</th>
                                <td><input type="text" id="" value="{{$data['price']}}" size="85" name="price" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>每人限购：</th>
                                <td><input type="text" id="" value="{{$data['limit']}}" size="85" name="limit" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>最低购买：</th>
                                <td><input type="text" id="" value="{{$data['min_limit']}}" size="85" name="min_limit" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>限购次数：</th>
                                <td><input type="text" id="" value="{{$data['limit_count']}}" size="85" name="limit_count" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>众筹成功比例：</th>
                                <td><input type="text" id="" value="{{$data['zhongchou_success_bili']}}" size="85" name="zhongchou_success_bili" class="common-text">%</td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>抢购时间：</th>
                                <td>

                                    <div class="row"><div class="col-md-6">
                                            <i class="fa fa-calendar"></i></span>
                                            <input type="text" name="add_time" class="ui_timepicker" id="aaaaa1" placeholder="选择日期时间" value="{{date('Y-m-d H:i:s',$data['add_time'])}}"  />
                                        </div></div></td>
                            </tr>
                            <script type="text/javascript">
                                $(function () {
                                    $("#aaaaa1").datetimepicker({
                                        //showOn: "button",
                                        //buttonImage: "./css/images/icon_calendar.gif",
                                        //buttonImageOnly: true,
                                        showSecond: true,
                                        timeFormat: 'hh:mm:ss',
                                        stepHour: 1,
                                        stepMinute: 1,
                                        stepSecond: 1
                                    })
                                    $("#aaaaa2").datetimepicker({
                                        //showOn: "button",
                                        //buttonImage: "./css/images/icon_calendar.gif",
                                        //buttonImageOnly: true,
                                        showSecond: true,
                                        timeFormat: 'hh:mm:ss',
                                        stepHour: 1,
                                        stepMinute: 1,
                                        stepSecond: 1
                                    })

                                })
                            </script>
                            <tr>
                                <th><i class="require-red">*</i>结束时间：</th>
                                <td><div class="row"><div class="col-md-6">
                                            <i class="fa fa-calendar"></i></span>
                                            <input type="text" name="end_time" class="ui_timepicker" id="aaaaa2" placeholder="选择日期时间" value="{{date('Y-m-d H:i:s',$data['end_time'])}}" / >
                                        </div></div></td>

                            </tr>
                            <tr>
                                <td>认购介绍</td>
                                <td><textarea name="info" cols=100 rows=20>{{$data['info']}}</textarea>
                                </td>
                            </tr>

                            <tr>
                                <th></th>
                                <td>
                                    <input type="hidden" value="{{$data['id']}}" name="id">
                                    <input type="submit" value="提交" class="btn btn-primary btn6 mr10">
                                    <a href=""><input type="button" value="返回"  class="btn btn6"></a>
                                </td>
                            </tr>
                            </tbody></table>
                    </div>
                </div>

            </form>
        </div>
    </div>
    </div>

@endsection
@section('footer')
    <script language="javascript" src="/plugin/kindeditor/jquery.tools.min.js"></script>
    <script language="javascript" src="/plugin/kindeditor/kindeditor-min.js"></script>
    <script language="javascript" src="/plugin/kindeditor/zh_CN.js"></script>
    <script language="javascript">
        $(document).ready(function(){
            $('#all').click(function(){
                $('.id').attr('checked',true);
            });
            $('#all_return').click(function(){
                $('.id').attr('checked',false);
            });
            $('#dels').click(function(){

                f = 0;
                $('.id').each(function(){
                    if($(this).attr('checked')) f = 1;
                });

                if(f==0){
                    alert('请选择要删除的项！');
                }else{
                    $('#formid').submit();
                }
            });
            $('#add').click(function(){
                location.href="?s=Admin/Issue/add";
            });
        });

        var editor;
        KindEditor.ready(function(K) {
            editor = K.create('textarea[name="info"]', {
                resizeType : 1,
                allowPreviewEmoticons : false,
                allowImageUpload : true,
                items : [
                    'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'image', 'link']
            });
        });
    </script>
    <script>
        function show_bl(){
            if($('#re_forzen').val()==0){
                $('#re_span').show();
                $('#re_bl').attr("disabled",false);
                $('#re_cycle').show();
            }else{
                $('#re_span').hide();
                $('#re_bl').attr("disabled",true);
                $('#re_cycle').hide();
            }

        }
    </script>
    <script>
        $(".sub-menu").eq(5).show();
        $(".sub-menu").eq(5).children("li").eq(0).addClass("on");
    </script>
@endsection